package cd.zhixuan.utils.sample;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.NonNull;

import cd.zhixuan.utils.LogTools;
import cd.zhixuan.utils.PermissionTools;
import cd.zhixuan.utils.dialog.Toaster;
import cd.zhixuan.utils.ui.ISeekBar;


public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        SampleSeekBar ssb = findViewById(R.id.ssb);
        ssb.setMax(30);
        ssb.setMin(0);
        ssb.setProgress(9);
        ssb.setOnProgressListener(new ISeekBar.OnProgressListener() {
            @Override
            public void handStart() {
                LogTools.d("handStart");
            }

            @Override
            public void handFinished() {
                LogTools.d("handFinished");
            }

            @Override
            public void progress(int lastProgress, int curProgress, boolean hand) {
                LogTools.d("lastProgress = " + lastProgress + " , curProgress = " + curProgress + " , hand = " + hand);
            }
        });

                ssb.updateProgress();
    }

    public void onClick(View view) {
        clickOther();
    }

    private int count = 0;

    private void clickOther() {
//        if (toastDialog == null) {
//            toastDialog = new Toaster(this);
//        }
//        toastDialog.show("toast " + count++, 3000);
//        findApp("SampleAutoUI");
        Toaster.toast("toast" + count++, 3000);

    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
        PermissionTools.listen(this, requestCode, permissions, grantResults);
    }
}